selected = new Object;
count = 0;

$(function(){

   $(".cb").attr('checked' , false);

   $(".cb").click(function(ev){
       //var target = ev.originalTarget;
       var target = $(ev).target;
       if (target == null)
       {
           target = ev.target;
       }
       var person_id = $(target).attr('id');
       var checked = $(target).attr('checked');
       selected[person_id] = checked;
   });


   $("#person_form").submit(function(){
     
       count = 0;
       for (var i in selected)
       {
           if (selected[i] == true)
           {
               count++;
           }
       }
  
       $("#submitbutton").attr('disabled', true);
       if (count > 20)
       {
           alert('你只能选择20个人！ 请返回重新选择！');
           $("#submitbutton").removeAttr('disabled');
           return false;
       }
       
       return true;
   });

   
});


